﻿
using Maticsoft.BLL;
using Maticsoft.Model;

using System;
using System.Text;
using System.Web.UI.HtmlControls;
using Utils;

public partial class WebPage_SheZhi_Youjian : SystemBBasePage
{
    protected bool mailssl = false;

    private Maticsoft.BLL.System systems = new Maticsoft.BLL.System();

    private void getEmail()
    {
        StringBuilder builder = new StringBuilder();
        Maticsoft.Model.System model = new Maticsoft.Model.System();
        model = this.systems.GetModel(1);
        this.mail_host.Value = model.mailhost;
        this.mail_port.Value = model.mailport;
        this.mail_user.Value = model.mailuser;
        this.mail_pass.Value = model.mailpass;
        this.mail_form.Value = model.mailfrom;
        this.mail_reply.Value = model.mailreply;
        this.mailssl = model.MailSSL;
        this.mail_interval.Value = model.mailinterval.ToString();
        this.subscribe_helpphone.Value = model.subscribehelpphone;
        this.subscribe_helpemail.Value = model.subscribehelpemail;
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        this.HeaderControl1.Select = "shezhi";
        if (!base.IsPostBack)
        {
            this.getEmail();
        }
        if (base.Request.HttpMethod == "POST")
        {
            this.setEmail();
        }
    }

    private void setEmail()
    {
        Maticsoft.Model.System model = new Maticsoft.Model.System();
        model = this.systems.GetModel(1);
        model.mailhost = this.mail_host.Value.Trim();
        model.mailport = this.mail_port.Value.Trim();
        model.mailuser = this.mail_user.Value.Trim();
        model.mailpass = this.mail_pass.Value.Trim();
        model.mailfrom = this.mail_form.Value.Trim();
        model.mailreply = this.mail_reply.Value.Trim();
        model.mailinterval = new int?(int.Parse(this.mail_interval.Value.Trim()));
        model.subscribehelpphone = this.subscribe_helpphone.Value.Trim();
        model.subscribehelpemail = this.subscribe_helpemail.Value.Trim();
        model.MailSSL = Helper.GetBool(base.Request["mailssl"], false);
        this.mailssl = Helper.GetBool(base.Request["mailssl"], false);
        this.systems.Update(model);
        base.SetSuccess("设置成功");
    }
}


